package prvydevw.servlet;

import java.util.ArrayList;
import java.util.List;
import java.util.Stack;

/**
 *
 * @author ivo
 */
public class JsonResponse
{
    private List<Notification> messages = new ArrayList<Notification>();
    private Object object;
    private String status = "ok";
    
    public JsonResponse(Stack<Notification> notifications, Object object)
    {
        while(!notifications.empty()) {
            Notification notification = notifications.pop();
            
            if (notification.getType() != null && notification.getType().equals("error")) {
                status = "error";
            }
            
            this.messages.add(notification);
        }
        
        this.object = object;
    }

    public List<Notification> getNotifications() {
        return messages;
    }

    public void setNotifications(List<Notification> notifications) {
        this.messages = notifications;
    }

    public Object getObject() {
        return object;
    }

    public void setObject(Object object) {
        this.object = object;
    }
    
    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }
}
